package com.wk1un2.util;

import com.google.gson.Gson;

public class Result {
	private boolean success;
	private int code;
	private String msg;
	private int count;
	private Object data;

	public Result(int code, String msg, int count, Object data) {
		this.code = code;
		this.msg = msg;
		this.count = count;
		this.data = data;
	}

	public Result(boolean success, int code, String msg, int count, Object data) {
		this.success = success;
		this.code = code;
		this.msg = msg;
		this.count = count;
		this.data = data;
	}

	public Result() {
		super();
	}

	/**
	 * @return the code
	 */
	public int getCode() {
		return code;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(int code) {
		this.code = code;
	}

	/**
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * @param msg the msg to set
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}

	/**
	 * @return the count
	 */
	public int getCount() {
		return count;
	}

	/**
	 * @param count the count to set
	 */
	public void setCount(int count) {
		this.count = count;
	}

	/**
	 * @return the data
	 */
	public Object getData() {
		return data;
	}

	/**
	 * @param data the data to set
	 */
	public void setData(Object data) {
		this.data = data;
	}

	public static Result ok(Object list) {
		Result result = new Result();
		result.setCode(1);
		result.setData(list);
		return result;
	}

	public static Result ok(String msg) {
		Result result = new Result();
		result.setCode(1);
		result.setMsg(msg);
		return result;
	}

	public static String Result(int code, String msg, int count, Object data) {
		Result res = new Result();
		res.code = code;
		res.msg = msg;
		res.count = count;
		res.data = data;
		Gson gson = new Gson();
		return gson.toJson(res);

	}
}
